<?php
/*
 * This is where the author can view the pages that need approval
 * This HTML is inserted into the Dashboard page using JQuery
 */
session_start();
require_once('includes/dbfunctions.php');

if (!isset($_SESSION['User'])) {
    require ("login.php");
    exit;
}

//get the SQL array of pages awaiting approval for current user
$output = authorDash($_SESSION['User']);

?>
<h3>Pages awaiting approval</h3>
<table width="700" id="authorDash">
    <tr>
        <th scope="col">Page Title</th>
        <th scope="col">Page Description</th>
        <th scope="col">Date Submitted</th>
        
    </tr>
    <?php
    $i=0;
    while ($i < count($output))
    {
        echo ("<tr>");
        $alias = $output[$i]['Alias'];
        echo ("<td scope=\"col\"><a href=\"../preview.php?page=$alias\" target=\"_blank\">".$output[$i]['Title']."</a></td>");

        echo ("<td scope=\"col\">".$output[$i]['Desc']."</td>");
        //if LastAuthor is blank, look at author instead and choose date created
        //and then make the date more readable
        if ($output[$i]['LastAuthor'] == '')
            $prettydate = date("m/d/Y", strtotime($output[$i]['Date']));
        else 
            $prettydate = date("m/d/Y", strtotime($output[$i]['LastDate']));
        
        echo ("<td scope=\"col\">".$prettydate."</td>");
        
        echo ("</tr>");
        $i++;
    }
    ?>

</table>
